package com.scs.application.modules.wm.enums;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* @Description： ***
 * <pre>
 *     wm_work_order.bus_type 类型定义，相关使用必须引用此类定义的。
 *     有新增类型，请同时添加到 WorkOrderTypeAll
 * </pre>
*/
@Slf4j
public class WorkOrderType {
    /*所有类型 */
    static public List<String> WorkOrderTypeAll;

    public static void init() {
        //将WorkOrderType下面所有String变量追加到 WorkOrderTypeAll中
        WorkOrderTypeAll= new ArrayList<String>();
        Arrays.stream(WorkOrderType.class.getDeclaredFields()).filter(fieldFilter -> fieldFilter.getType() == String.class).forEach(field -> {
            String fieldValue;
            try {
                fieldValue = (String) field.get(WorkOrderType.class);
                if (WorkOrderTypeAll.contains(fieldValue)) {
                    log.error("WorkOrderType类型值{} 重复",fieldValue);
                    System.exit(0);
                }
                WorkOrderTypeAll.add(fieldValue);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        });
    }

    /******************************************入库类型开始********************************************************/
    /*手动入库*/
    public static final String IN_MANUAL = "IN_MANUAL";
    /*采购入库*/
    public static final String IN_ASN = "IN_ASN";
    /*跟台包入库*/
    public static final String IN_PACKAGE = "IN_PACKAGE";
    /*期初入库*/
    public static final String IN_INIT = "IN_INIT";
    /*科室退货入库*/
    public static final String IN_DEPT_RETURN = "IN_DEPT_RETURN";
    /*调拨入库 不同物理仓库*/
    public static final String IN_SHIFT = "IN_SHIFT";
    /*调拨入库，同物理仓库，OW=one warehouse */
    public static final String IN_SHIFT_OW = "IN_SHIFT_OW";
    /*科室消耗 冲红入库*/
    public static final String IN_USE_RED = "IN_USE_RED";
    /*病人消耗模块、HIS退费或者病人消耗冲红*/
    public static final String IN_OPRT_RED = "IN_OPRT_RED";

    public static final String IN_SCANNER = "IN_SCANNER";

    // 数量入库
    public static final String IN_NUMBER = "IN_NUMBER";

    /******************************************入库类型结束********************************************************/


    /******************************************出库类型开始********************************************************/
    /*科室消耗单*/
    public static final String OUT_USE = "OUT_USE";
    /*供应商退货出库，手术清点出库*/
    public static final String OUT_SP = "OUT_SP";
    /*调拨出库，不同物理仓库*/
    public static final String OUT_SHIFT = "OUT_SHIFT";
    /*调拨出库，同物理仓库，OW=one warehouse */
    public static final String OUT_SHIFT_OM = "OUT_SHIFT_OW";
    /*病人消耗模块、HIS接口消耗*/
    public static final String OPRT_USE = "OPRT_USE";
    /*数量出库*/
    public static final String OUT_NUMBER = "OUT_NUMBER";

    /******************************************出库类型结束********************************************************/


    /******************************************出库类型组合开始********************************************************/
    /*所有需要生成记账的入库类型*/
    final static public List<String> WorkOrderTypeBillInAll = Arrays.asList("'IN_MANUAL'","'IN_ASN'","'IN_PACKAGE'","'IN_INIT'");
    final static public List<String> WorkOrderTypeIn = Arrays.asList(IN_MANUAL, IN_ASN, IN_PACKAGE, IN_INIT);

    /*配送出库类型清单*/
    final static public List<String> BUSTYPE_DIST = Arrays.asList("'OUT_DIST'","'AUTO_APPLY'","'AUTO_PURCHASE'");

    /*科室消耗类型清单*/
    final static public List<String>  BUSTYPE_DEPTUSE =Arrays.asList("'OUT_USE'");

    /*病人计费类型清单*/
    final static public List<String>  BUSTYPE_PATIENT =Arrays.asList("'OPRT_USE'");

    /*病人计费类型清单*/
    final static public List<String>  BUSTYPE_ALL =  (List<String>) CollectionUtils.union((List<String>) CollectionUtils.union(BUSTYPE_DIST,BUSTYPE_DEPTUSE),BUSTYPE_PATIENT) ;
    /******************************************出库类型组合结束********************************************************/

    //冲红业务列表
    /*病人计费类型清单*/
    final static public List<String>  BUSTYPE_RED_ALL =  Arrays.asList(IN_DEPT_RETURN,IN_USE_RED,IN_OPRT_RED);
}
